<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>登录</title>
		<link rel="stylesheet" type="text/css" href="../css/login.css" />
		<script type="text/javascript" src="../js/boot.js"></script>
		<script type="text/javascript" src="../js/common/http.js"></script>
		<script type="text/javascript" src="../js/login.js"></script>
	</head>

	<body>

		<!-- 登录body -->
		<div class="logDiv">
			<img class="logBanner" src="../img/login/logBanner.png" />
			<div class="logGet">
				<!-- 头部提示信息 -->
				<div class="logD logDtip">
					<p class="p1">登录</p>
				</div>
				<!-- 输入框 -->
				<div class="lgD">
					<img class="img1" src="../img/login/logName.png" />
					<input type="text" id="username" placeholder="输入用户名" />
				</div>
				<div class="lgD">
					<img class="img1" src="../img/login/logPwd.png" />
					<input id="password" type="password" placeholder="输入用户密码" />
				</div>
				<div class="logC">
					<a href="javascript:login();" target="_self"><button>登 录</button></a>
				</div>
			</div>
		</div>
		<!-- 登录body  end -->

		<!-- 登录页面底部 -->
		<div class="logFoot">
			<p class="p1">版权所有：南通速维工程设备有限公司</p>
			<p class="p2">123456789</p>
		</div>
		<!-- 登录页面底部end -->

	</body>

	<script type="text/javascript">

// TODO 用这个方式查找图片路径，再动态处理或更换
// alert($("[src$='.png']"));

		function login() {
			//debugger
			var username = $("#username").val();
			var password = $("#password").val();
			if(username == '') {
				alert("用户名不能为空！");
				return;
			}
			if(password == '') {
				alert("密码不能为空！");
				return;
			}
			params = {
				"loginName": username,
				"loginPassword": password
			};
			//debugger
			http.post("/user/any/login.do", params, function(data) {
				if(data.success) {
					//debugger
					localStorage.setItem('_token', data.dataMap._token);
					var user = data.data;
					user.token = data.dataMap.token;
					localStorage.setItem('user', mini.encode(user));
					window.location.href = "./dashboard.html";
				} else {
					alert(data.message);
				}
			});
		}
	</script>

</html>